<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>vue页面</title>
	</head>
	<body>
		<div id="app">
			<h1><button type="button" @click="sendMsg">发送请求</button></h1>
		</div>
		<script src="js/vue.js"></script>
		<script src="js/vue-router.js"></script>
		<!-- uni 的 SDK -->
		<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
		<!-- JSbridge -->
		<script src="js/uni-js-bridge.es5.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/vconsole.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios.js"></script>
		<script>
			let app = new Vue({
				el: '#app',
				data() {
					return {
						msg: '111'
					}
				},
				created() {
					UniJsBridge.registerHandler('test', (data, callback) => {
						console.log(data)
						callback({
							code: 0,
							data: '返回的数据',
							msg: 'success'
						})
					})
				},
				mounted() {
					// 初始化
					let vConsole = new VConsole();
					// console.log('Hello world', window.location.href, window);
				},
				methods: {
					sendMsg: function() {
						// this.hello();
						this.word();
					},
					hello() {
						axios.get('http://192.168.18.251:7001/hello').then(res => {
							console.log(res)
						}).catch(e => {
							console.log(e)
						})
					},
					word() {
						axios.post('http://192.168.18.251:7001/word').then(res => {
							console.log(res)
						}).catch(e => {
							console.log(e)
						})
					}
				}
			})
		</script>
	</body>
</html>
